﻿using System;
using IceZero.DataStore.Models;

namespace IceZero.DataStore.InitDB
{
    /// <summary>
    /// 数据库初始化器
    /// </summary>
    public class UserDomainDBInitializer
    {

        public void Initialize()
        {
            InitUser();
        }

        public void InitUser()
        {
            var dataStore = new UserDataStore();
            if (dataStore.Count() > 0)
            {
                return;
            }
            dataStore.AddUser(new User()
            {
                Id = "a101000000000000000000000abc123",
                Account = "admin",
                Password = "abc123",
                CreateTime = DateTime.Now,
                Name = "Administrator",
                Remark = "内置超管账号"
            });

            dataStore.AddUser(new User()
            {
                Id = "a101000000000000000000000abc456",
                Account = "root",
                Password = "abc123",
                CreateTime = DateTime.Now,
                Name = "root",
                Remark = "内置超管账号2"
            });
            dataStore.AddUser(new User()
            {
                Id = Guid.NewGuid().ToString("N"),
                Account = "guest",
                Password = "123456",
                CreateTime = DateTime.Now,
                Name = "guest user",
                Remark = "内置普通账号"
            });
        }
    }
}
